function show_qrcode() {
    var url = window.location.href;
    var info = DOUBAN.parse_url(url);

    if ('event' == info.type || 'note' == info.type) {
        url = 'http://m.douban.com/' + info.type + '/' + info.id + '/';
    } else if ('subject' == info.type || 'photos' == info.category) {
        url = 'http://m.douban.com/' + info.category + '/' + info.type + '/' + info.id + '/';
    }
    
    var QRErrorCorrectLevel = {
        L : 1,
        M : 0,
        Q : 3,
        H : 2
    };

    console.log("generate QRCode for " + url);

    var container = $('div#content div.aside');

    container.append("<div id='qrcode' style='text-align: center'></div>");

    $('#qrcode').qrcode({
        text: url,
        typeNumber: 4,
        correctLevel: QRErrorCorrectLevel.M
    }).append("<br/><a href='" + url + "'>访问手机豆瓣</a>");
}

read_option('qrcode_chart', function (key, value) {
    if (value) {
        show_qrcode();
    }
});